package de.lot.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * StudentLearningOutcome unites a student and several positions to form an
 * examination consisting of one or more positions.
 *
 * @see Position
 *
 * @author Stefan Kohler <kohler.stefan@gmail.com>
 */
@Entity
@Table(name = "STUDENTLEARNINGOUTCOME")
public class StudentLearningOutcome implements Serializable {

    private Long id;
    private Date date;
    private boolean inCooperationWithCompany;
    private Student student;
    private String comment;
    private Set<Position> positions = new HashSet<Position>(0);

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @NotNull
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public boolean isInCooperationWithCompany() {
        return inCooperationWithCompany;
    }

    public void setInCooperationWithCompany(boolean inCooperationWithCompany) {
        this.inCooperationWithCompany = inCooperationWithCompany;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "STUDENT_ID", nullable = false)
    @NotNull
    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    @Length(max = 1000)
    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "studentLearningOutcome")
    public Set<Position> getPositions() {
        return positions;
    }

    public void setPositions(Set<Position> positions) {
        this.positions = positions;
    }
}
